﻿<UserControl x:Class="SL_Drag_Drop.sucDragDropListbox2"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:dd="clr-namespace:SL_Drag_Drop_BaseClasses;assembly=SL_Drag_Drop_BaseClasses"     
    >
    <Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"></ColumnDefinition>
        <ColumnDefinition Width="Auto"></ColumnDefinition>
        <ColumnDefinition></ColumnDefinition>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition></RowDefinition>
    </Grid.RowDefinitions>

    <TextBlock Text="Dragging and dropping in an ItemsControl" 
                       FontSize="14" Margin="10"
                       HorizontalAlignment="Left" VerticalAlignment="Top"
                       Grid.ColumnSpan="3"></TextBlock>

        <TextBlock FontSize="11" TextWrapping="Wrap" Margin="10"
                       HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Row="1"
                       Grid.ColumnSpan="3">
                <Run Text="This example demonstrates more features of the Drag and Drop Manager.  You can drag each item in the ItemsControl (= pretty basic control, same logic of course applies to higher level controls like the ListBox) to another position.  Important to notice here: the dragbar is disabled, meaning you can start dragging by clicking anywhere on the item."></Run>
        </TextBlock>




    <StackPanel Orientation="Vertical" HorizontalAlignment="Center"
                           Grid.Row="2" Grid.Column="0" Margin="10">
        <TextBlock FontSize="14" Margin="0,0,0,10">The list of items</TextBlock>

            <ItemsControl x:Name="lstbxItems">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <dd:DropTarget DragSourceDropped="DropTarget_DragSourceDropped"
                                       Width="200" Height="70" >
                            <dd:DropTarget.DropBorderBrush>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFD83F00" Offset="0"/>
                                    <GradientStop Color="#FFF65E00" Offset="1"/>
                                </LinearGradientBrush>
                            </dd:DropTarget.DropBorderBrush>
                            <dd:DropTarget.Content>
                                <dd:DragSource AllDropTargetsValid="true" AutoFitGhost="true"
                                               ShowSwitchReplaceAnimation="False" DragHandleMode="FullDragSource">

                                    <Grid Width="180" Height="50" Background="#FF70BFF5" Margin="5">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="60" ></ColumnDefinition>
                                            <ColumnDefinition></ColumnDefinition>
                                        </Grid.ColumnDefinitions>
                                        <Rectangle Grid.ColumnSpan="2" Stroke="Gray" StrokeThickness="1">
                                            <Rectangle.Fill>
                                                <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0">
                                                    <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                                    <GradientStop Color="#F9FFFFFF" Offset="0.267"/>
                                                    <GradientStop Color="#B2FFFFFF" Offset="0.53"/>
                                                    <GradientStop Color="Transparent" Offset="1"/>
                                                </LinearGradientBrush>
                                            </Rectangle.Fill>
                                        </Rectangle>
                                        <Image VerticalAlignment="Center" 
                                               HorizontalAlignment="Center"
                                               Source="{Binding ImageSrc}"></Image>
                                        <TextBlock Text="{Binding Dummy}" Grid.Column="1"
                                                   FontSize="14" VerticalAlignment="Center"></TextBlock>
                                    </Grid>

                                    <dd:DragSource.Ghost>
                                        <Grid Background="#FF70BFF5" Opacity="0.1">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="60" ></ColumnDefinition>
                                                <ColumnDefinition></ColumnDefinition>
                                            </Grid.ColumnDefinitions>
                                            <Rectangle Grid.ColumnSpan="2" Stroke="Gray" StrokeThickness="1">
                                                <Rectangle.Fill>
                                                    <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0">
                                                        <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                                        <GradientStop Color="#F9FFFFFF" Offset="0.267"/>
                                                        <GradientStop Color="#B2FFFFFF" Offset="0.53"/>
                                                        <GradientStop Color="Transparent" Offset="1"/>
                                                    </LinearGradientBrush>
                                                </Rectangle.Fill>
                                            </Rectangle>
                                            <Image VerticalAlignment="Center" 
                                               HorizontalAlignment="Center"
                                               Source="{Binding ImageSrc}"></Image>
                                            <TextBlock Text="{Binding Dummy}" Grid.Column="1"
                                                   FontSize="14" VerticalAlignment="Center"></TextBlock>
                                        </Grid>
                                    </dd:DragSource.Ghost>
                                </dd:DragSource>

                            </dd:DropTarget.Content>
                        </dd:DropTarget>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>


        </StackPanel>

    </Grid>
</UserControl>
